﻿var formatPriority = function (e) {
    var sData = e.value;
    var showText;
    if (sData == "1") {
        showText = "<font color='red'>特急</font>";
    } else if (sData == "2") {
        showText = "<font color='green'>紧急</font>";
    } else {
        showText = "普通";
    }
   return showText;
}

var formatShow = function (e) {
    var row = e.record;
    var WorkFlowInstanceId = row["WorkFlowInstanceId"];
    var workflowId =row["WorkFlowId"];
    var taskCaption =  row["FlowCaption"];
    var url = '"' + "../../Crm/BasePages/WorkflowMap.aspx?WorkFlowInstanceId=" + WorkFlowInstanceId + "&workflowId=" + workflowId + '"';
    var title = '"' + taskCaption + '流程图"';
    return "<a href='javascript:transForForm(" + title + "," + url + ")'>流程图</a><br />";
}
var transForForm = function (title, url) {
    parent.addTabs(title, url);
    parent.NeedRefreshPage = this;
}

//格式化业务名列
var formatCaption = function (e) {
    var row = e.record;
    var OperatorInstanceId = row["operatorInstanceId"];
    var WorkFlowNo = row["WorkFlowNo"];
    var WorkTaskInstanceId = row["WorkTaskInstanceId"];
    var TaskName = row["TaskCaption"];
    var IsDisplay = row["IsDisplay"];
    var sData = e.value;
    var title = '"' + e.value + '"';
    var url = '"' + "/Crm/BasePages/WorkTaskCtrlPage.aspx?title=" + sData + "&OperatorInstanceId=" + OperatorInstanceId + "&WorkTaskInstanceId=" + WorkTaskInstanceId + '"';
    var pOperatedDes = row["pOperatedDes"];
    if (TaskName.length > 1 && TaskName.substr(0, 2) == "查看") {
        url = '"' + "/Crm/BasePages/WorkTaskCtrlPage.aspx?view=check&title=" + sData + "&OperatorInstanceId=" + OperatorInstanceId + "&WorkTaskInstanceId=" + WorkTaskInstanceId + '"';
    } else {
        if (pOperatedDes.substr(pOperatedDes.length - 1, 1) == ',') {
            url = '"' + "/Crm/BasePages/WorkTaskCtrlPage.aspx?view=unDone&title=" + sData + "&OperatorInstanceId=" + OperatorInstanceId + "&WorkTaskInstanceId=" + WorkTaskInstanceId + '"';
        }
    }
    var html = "";
    var sum = 0;
    var urls = "/Images/new4.gif";
    if (IsDisplay != "") {
        var isDplay = "";
        var isnull = "  ";
        isDplay = IsDisplay.split(',');
        for (i = 0; i < isDplay.length; i++) {
            if (isDplay[i] = "admin") {
                sum = 1;
                break;
            }
        }
        if (sum == 0) {
            html = "<a href='javascript:transForForm(" + title + "," + url + ")'>" + sData + "&nbsp;&nbsp;&nbsp;<img src= " + urls + "></a><br />";
        }
        else {
            html = "<a href='javascript:transForForm(" + title + "," + url + ")'>" + sData + "</a><br />";
        }
    }
    else {
        html = "<a href='javascript:transForForm(" + title + "," + url + ")'>" + sData + "&nbsp;&nbsp;&nbsp;<img  src= " + urls + "></a><br />";
    }
    return html;

}

var formatIsDisplay = function (e) {
    var row = e.record;
    var sData = e.value;
    var items = "Admin";
    var WorkFlowInstanceId = row["WorkFlowInstanceId"];
    var WorkFlowNo = row["WorkFlowNo"];
    html = "";
    var sum = 0;
    if (sData != "") {
        var isDplay = "";
        isDplay = sData.split(',');
        for (i = 0; i < isDplay.length; i++) {
            if (isDplay[i] = "Admin") {
                sum = 1;
                break;
            }
        }
        if (sum == 0) {
            var url = "/Images/new1.gif";
            html = "<a><img src= " + url + "></a><br />";
        }
    }
    else {
        var url = "/Images/new1.gif";
        html = "<a><img src= " + url + "></a><br />";
    }
    return html;
}
//自动义双击方法
function CustomDbClick() { }